﻿@model Sub.TaskPlanningDesk.WebSite.ViewModels.Tasks.TaskModel
@{
	ViewBag.Title = Model.IsNew ? "Create new task" : "Edit task";
}

@Html.NavProject(Model.Project, false, true)
@Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")
@using (Html.BeginForm(TheActions.Task.Edit, TheControllers.Task ))
{
	<h3>
		@(Model.IsNew ? "Create new task" : "Edit task")
	</h3>
	<div class="editor-label">
		@Html.LabelFor(m => m.Overview)
	</div>
	<div class="editor-field">
		@Html.TextBoxFor(m => m.Overview)
		@Html.ValidationMessageFor(m => m.Overview)
	</div>

	<div class="editor-label">
		@Html.LabelFor(m => m.Description)
	</div>
	<div class="editor-field">
		@Html.TextAreaFor(m => m.Description)
		@Html.ValidationMessageFor(m => m.Description)
	</div>
	<p>
		@Html.HiddenFor(m => m.ID)
		@Html.HiddenFor(m => m.Project.ID)
	</p>
	<p>
		@if (!Model.IsNew) {
			<input type="button" value="Delete" onclick="return DeleteTask();" />
			<label>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;</label>
		}
		<input type="submit" value="Save" />
	</p>
}
<script type="text/javascript">
	function DeleteTask() {
		if (!confirm('Are you sure?'))
			return;

		window.location = '/@(TheControllers.Task)/@(TheActions.Task.Delete)?taskID=@(Model.ID)&projectID=@(Model.Project.ID)';
	}
</script>

